<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@taglib uri="/struts-tags" prefix="s"%>
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OA协同办公系统</title>
<link type="text/css" rel="stylesheet" href="css/table.css">
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/openwindow.js"></script>
<script type="text/javascript" src="js/file.js"></script>
<SCRIPT type="text/javascript" src="js/workflow.js"></SCRIPT>
<script src="js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
		<style type="text/css">
		body,td,th {
			background-color:white;
			font-family: "宋体";
			font-size: 12px;
		}
		</style>
<script type="text/javascript">
$(function(){
	var nodeId=$("#currentNodeId").val();
	var param={"nodeIds":nodeId};
	var area=$("textarea");
	for(var i=0;i<area.length;i++){
		$("#"+area[i].id).attr("style","width:550px; height:100px; border:0px; overflow-y:auto;");
	}
	$.post("initFormValueWrite.action",param,function(data){
		var proportyList=data.proportyList;
		for(var i=0;i<proportyList.length;i++){
			if(proportyList[i].type=='word'){
				$("#word").removeAttr("disabled");
				$("#word").removeAttr("onclick");
				var name=proportyList[i].columnName;
				$("#word").bind('click',function(){
					draftWord(name,3);
				});
			}else if(proportyList[i].type=='upload'){
				$("#upload").removeAttr("disabled");
			}else{
			$("#"+proportyList[i].columnName).removeAttr("disabled");
			var id=$("#"+proportyList[i].columnName);
				if($(id).is("textarea")){
					$(id).attr("tableIndex","yes");
					$(id).attr("style","width:80%; height:100px; border:1; overflow-y:auto");
					$(id).parent().append("<input type=\"button\" class=\"button_02\" onclick=\"OpenComment('"+proportyList[i].columnName+"')\" value=\"办公语\">");
				}
			}
		}
			var inputs=$("body").find("input[name=\"word\"]");
			if(inputs[0]!=undefined&&inputs[0]!=''){
				if($("#word").attr("disabled")){
				$("#word").removeAttr("disabled");
				$("#word").removeAttr("onclick");
				$("#word").bind('click',function(){
					draftWord(inputs[0].id,0);
				});
				}
			}
	},"json");
	formContent();
});
	
	function draftWord(val,type) {
		var id=$("#"+val).val();
		var url = "wordEditor.action?wordId="+id+"&proportyName="+val+"&status="+type;
		openWindow(url,screen.width,screen.height);
	}
	
	function saveText(val,id){
		$("#"+val).val(id);
	}
	
	function OpenComment(msg){
		var massage=$("#"+msg).val();
		var sign="";
		var URL = "getWorkLanAll.action?location="+msg+"&message="+sign;
		openWindow(encodeURI(encodeURI(URL)),400,300);
	}
	
	function SetVerifyComment(location,message){
		var msg=$("#"+location).val();
		$("#"+location).val(message);
	}
function submitNextNode(id,type){
	if(type=='2'){
		getcandidateR(id);
	}else if(type=='3'){
		getorguserR(id);
	}else if(type=='5'){
		selectUser(id);
	}else{
		updateNextStep(id,'');
	}
}	
	
function setValue(value,id){
	updateNextStep(id,value);
}

function formContent(){
	var tableId=$("#tableId").val();
	var formId=$("#formId").val();
	var param={"tableId":tableId,"formId":formId};
	$.post("getFormContent.action",param,function(data){
		var jsondata=data.jsonData;
		var jsonObj=eval(jsondata);
		var proportyList=data.proportyList;
		for(var i=0;i<proportyList.length;i++){
			if(proportyList[i].columnName==jsonObj[i+1].name){
				$("#"+proportyList[i].columnName).val(jsonObj[i+1].value);
			}
			if(proportyList[i].type=='upload'){
				downloadFile(proportyList[i].columnName);				
			}
		}

	},"json");
}

$(function(){
	var form=$("#formId").val();
	var userId=$("#draftUserId").val();
	var param={"userId":userId};
	if(form=='86'){
		$.post("getMyHolidayTotal.action",param,function(data){
			 var preHoliday=data.preHoliday;
			 var nowHoliday=data.nowHoliday;
			 var total=data.total;
			$("#holiday").html("去年剩余假期 "+preHoliday+" 天,今年有假期 "+nowHoliday+" 天,全年共有假期 "+(parseInt(preHoliday)+parseInt(nowHoliday))+" 天,已休假 "+total+" 天,还剩 "+(parseInt(preHoliday)+parseInt(nowHoliday)-parseInt(total))+" 天");
		},"json");
	}else if(form=='341'){
		$.post("getMyLeaveTotal.action",param,function(data){
			var leave=data.leave;
			$("#holiday").html("今年已请事假 "+leave.days1+" 天,今年已请病假 "+leave.days2+" 天");
		},"json");
	}
});


</script>
  </head>
  
<body>
<div align="center" style="color:#CC6600;font-size: 16px;" id="holiday"></div>
<input type="hidden" id="userName" value="${sessionScope.userInfo.name}">
<input id="status" type="hidden" value="${status}">
<input id="currentNodeId" type="hidden"  value="${instance.nodeId}">
<input id="draftUserId" type="hidden"  value="${instance.userId}">
<form action="" method="post" name="documentForm" >
<input type="hidden" id="currentPage" value="${currentPage}">
<input id="tableId" type="hidden" value="${tableId}">
<input id="flowId" type="hidden" value="${workflow.id}">
<input id="formId" type="hidden" value="${definition.formId}">
<input id="instanceId" type="hidden" value="${instanceId}">
<div id="nodebutton" style="margin-left: 30px;margin-top: 10px">
	<table>
	<tr>
		<td>
		<c:forEach items="${nodeList}" var="node">
		<input type="button" class="button_04" id="${node.id}" onclick="submitNextNode('${node.id}','${node.actorType}')" value="${node.name}">
		</c:forEach>
		</td><td>
		<input type="button" id="notShow" class="button_02"  value="退回" onclick="backShow(this.id)" />
	</td><td>
	<span id="backList" style="display:none">
		<s:select id="backNodeId" list="backNotes" listKey="id" listValue="name" headerKey="" headerValue="发起人" theme="simple"></s:select><input type="button" class="button_02"  value="确定" onclick="reject()" /><input type="button" class="button_02" id="yesShow"  value="取消" onclick="backShow('backList')" />
	</span></td>
	<td><input type="checkbox"  value="1" name="message">短信提醒</td>
	<td>
		<input type="button" class="button_04"  value="流程查看" onclick="flowLook('${instanceId}');" />
	</td></tr></table>
	</div>
	${definition.content}
	<p></p>
	<div align="center">
	<table><tr>
		<td>
		<c:forEach items="${nodeList}" var="node">
		<input type="button" class="button_04" id="${node.id}" onclick="submitNextNode('${node.id}','${node.actorType}')" value="${node.name}">
		</c:forEach>
		</td><td>
		<input type="button" id="notShow2" class="button_02"  value="退回" onclick="backShow(this.id)" />
	</td><td>
	<span id="backList2" style="display:none">
		<s:select id="backNodeId" list="backNotes" listKey="id" listValue="name" headerKey="" headerValue="发起人" theme="simple"></s:select><input type="button" class="button_02"  value="确定" onclick="reject()" /><input type="button" class="button_02" id="yesShow"  value="取消" onclick="backShow('backList2')" />
	</span></td>
	<td><input type="checkbox"  value="1" name="message">短信提醒</td>
	</tr>
	</table>
	</div>
	
</form>
</body>
</html>
